//
//  BKSignVoucherNameViewCell.m
//  bestkeep
//
//  Created by yons on 16/12/5.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKSignVoucherNameViewCell.h"
#import "BKMainCommon.h"
#import "BKIntegralAllVoucherController.h"
#import "BK_OD_Color.h"
@interface BKSignVoucherNameViewCell ()
@property (nonatomic,strong)UILabel * lab_name;
@property (nonatomic,strong)UILabel * lab_AcTime;//活动时间
@property (nonatomic,strong)UIView  * view_line;
@property (nonatomic,strong)UILabel * lab_lookMore;
@property (nonatomic,strong)UIImageView * imgV_right;
@end
@implementation BKSignVoucherNameViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self){
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)initView{
    
    
    _lab_name=[UILabel new];
    _lab_name.text=@"兑换优惠券";
    _lab_name.textAlignment=NSTextAlignmentLeft;
    _lab_name.font=[UIFont systemFontOfSize:15];
    _lab_name.textColor=RGB(64, 64, 64);
    [self addSubview:_lab_name];
    [_lab_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(ApplicationBackGauge);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    _lab_AcTime=[[UILabel alloc]init];
    _lab_AcTime.text=@"";
    _lab_AcTime.textAlignment=NSTextAlignmentLeft;
    _lab_AcTime.font=[UIFont systemFontOfSize:14];
    _lab_AcTime.textColor=kOrderPriceRed;
    [self addSubview:_lab_AcTime];
    [_lab_AcTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(ApplicationBackGauge+80);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    _view_line=[UIView new];
    _view_line.backgroundColor=RGB(225, 226, 227);
    [self addSubview:_view_line];
    [_view_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(5);
        make.right.equalTo(self.mas_right).offset(-5);
        make.bottom.equalTo(self.mas_bottom).offset(-0.5);
        make.height.mas_equalTo(@(0.5));
    }];
    
    UIButton * btn=[[UIButton alloc]init];
    [self addSubview:btn];
    btn.backgroundColor=[UIColor  clearColor];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(0);
        make.bottom.equalTo(self.mas_bottom).offset(0);
        make.top.equalTo(self.mas_top).offset(0);
        make.width.mas_equalTo(@(ScreenWidth/2.0));
    }];
    
    _imgV_right = [UIImageView new];
    _imgV_right.backgroundColor = [UIColor clearColor];
    _imgV_right.alpha=0.6;
    [self addSubview:_imgV_right];
    _imgV_right.image=[UIImage imageNamed:@"BKIntegral_right_arrow"];
    [_imgV_right mas_makeConstraints:^(MASConstraintMaker *make){
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.width.mas_equalTo(@(16*0.5));
        make.height.mas_equalTo(@(26*0.5));
    }];
    
    _lab_lookMore=[UILabel new];
    _lab_lookMore.text=@"查看更多";
    _lab_lookMore.textAlignment=NSTextAlignmentLeft;
    _lab_lookMore.font=[UIFont systemFontOfSize:13];
    _lab_lookMore.textColor=RGB(136, 136, 136);
    _lab_lookMore.userInteractionEnabled = YES;
    UITapGestureRecognizer *moreTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(moreTapAction)];
    [_lab_lookMore addGestureRecognizer:moreTap];
    [self addSubview:_lab_lookMore];
    [_lab_lookMore mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_imgV_right.mas_left).mas_offset(-10);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    
    
}

-(void)moreTapAction{
    BKIntegralAllVoucherController *allVC = [[BKIntegralAllVoucherController alloc]init];
    [[self viewController].navigationController pushViewController:allVC animated:YES];
}
//得到视图控制器
- (UIViewController *)viewController {
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}



-(void)Set_lab_AcTime:(NSString *)time{
    if (time) {
        _lab_AcTime.text=[NSString stringWithFormat:@"%@",time];
    }
}



-(void)MoreHidden{
    _lab_lookMore.hidden=YES;
    _imgV_right.hidden=YES;
}
-(void)MoreShow{
    _lab_lookMore.hidden=NO;
    _imgV_right.hidden=NO;
}
+(CGSize)setSize:(id)data{
    if (!data) {
        return CGSizeZero;
    }else{
        return CGSizeMake(ScreenWidth,44);
    }
}
@end
























